package github.flandre.examplemod.common.world;

import github.flandre.examplemod.core.init.BlockInit;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.WorldGenRegistries;
import net.minecraft.world.gen.Heightmap;
import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
import net.minecraft.world.gen.feature.*;
import net.minecraft.world.gen.foliageplacer.BlobFoliagePlacer;
import net.minecraft.world.gen.foliageplacer.DarkOakFoliagePlacer;
import net.minecraft.world.gen.trunkplacer.DarkOakTrunkPlacer;
import net.minecraft.world.gen.trunkplacer.StraightTrunkPlacer;

import java.util.OptionalInt;

public class ExampleConfigFeature{
    //Features
    public static final ConfiguredFeature<BaseTreeFeatureConfig, ?> TreeConfig = Feature.TREE.withConfiguration((
            new BaseTreeFeatureConfig.Builder(
            new SimpleBlockStateProvider(BlockInit.EXAMPLE_LOG.get().getDefaultState()),
            new SimpleBlockStateProvider(BlockInit.EXAMPLE_LEAVES.get().getDefaultState()),
            new BlobFoliagePlacer(FeatureSpread.func_242252_a(2), FeatureSpread.func_242252_a(0), 3),
            new StraightTrunkPlacer(8, 2, 0),
            new TwoLayerFeature(1, 0, 1))).setIgnoreVines().build());

    //注册方法
    private static <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String key, ConfiguredFeature<FC, ?> configuredFeature) {
        return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, key, configuredFeature);
    }
}


//public static final ConfiguredFeature<BaseTreeFeatureConfig, ?> OAK =
//        register("oak", Feature.TREE.withConfiguration((
//                new BaseTreeFeatureConfig.Builder(
//                        new SimpleBlockStateProvider(Features.States.OAK_LOG),
//                        new SimpleBlockStateProvider(Features.States.OAK_LEAVES),
//                        new BlobFoliagePlacer(FeatureSpread.func_242252_a(2), FeatureSpread.func_242252_a(0), 3), new StraightTrunkPlacer(4, 2, 0), new TwoLayerFeature(1, 0, 1))).setIgnoreVines().build()));